using System.Collections.Generic;
using BSDS.Commands.Commands.Implementation;
using BSDS.Core.Infrastructure.Logging;
using BSDS.Core.Model.Services;

namespace BSDS.Commands.Commands.Creation.Implementation
{
    public class SchemaCommandCreator : CommandCreatorBase
    {
        private readonly AccountService accountService;
        private readonly Logger logger;

        public SchemaCommandCreator(AccountService accountService, Logger logger)
        {
            this.accountService = accountService;
            this.logger = logger;
        }

        protected override bool Supports(Dictionary<string, string> parameters)
        {
            return parameters.Count == 1 && parameters.ContainsKey("schema");
        }

        protected override ICommand Create(Dictionary<string, string> parameters)
        {
            var dataSourceName = parameters["schema"];

            return new SchemaCommand(accountService, logger, dataSourceName);
        }
    }
}